package com.whq.service.weixin.impl;

import com.whq.service.MarketingService;
import com.whq.service.MemberService;
import com.whq.service.weixin.EventsService;
import com.whq.weixin.entity.WeChatReceiveMsg;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 取消关注事件
 * @author 海易出行
 *
 */
@Service
public class UnsubscribeEventsServiceImpl implements EventsService {
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	MemberService memberService;
	
	@Autowired
	MarketingService marketingService;
	@Override
	public String response(WeChatReceiveMsg msg) throws Exception {
//		// 如果是事件推送信息
//		String event = msg.getEvent();
//		Member member = memberService.findMemberByOpenID(msg.getFromUserName());
//		W3AccessToken info = null;
//		try{
//			info = WeiXinUtils.getNickname(null,msg.getFromUserName());
//		}catch(Exception e){
//			info = new W3AccessToken();
//		}
//		if(null == info){
//			info = new W3AccessToken();
//		}
//		if(member != null){
//			logger.info("execute {} update {} begin .....",event,msg.getFromUserName());
//			Member member0 = new Member();
//			member0.setId(member.getId());
//			member0.setFocusType(0);//取消关注
//			if(StringUtils.isBlank(member.getImageUrl())){
//				member0.setImageUrl(info.getHeadimgurlreturn());
//			}
//			member0.setLasttimeModify(new Date());
//			memberService.updatePersonalMember(member0);
//			logger.info("execute {} update {} end .....",event,msg.getFromUserName());
//
//		}
		return "ok";

	}

}
